module;
#include <iostream>
#include <thread>

export module Code_2_1_1;

void do_something(int& i) {
	++i;
}

struct func
{
	int& i;
	func(int& i_) : i{ i_ } {}
	void operator()() {
		for (unsigned j = 0; j < 1000000; ++j) {
			do_something(i);
		}
	}

};

export
namespace Code_2_1_1 {
	void run_thread() {
		int some_local_state = 0;
		func my_func(some_local_state);
		std::thread my_thread(my_func);
		my_thread.detach();

	}
}
